float colormap_red(float x) {
    if (x < (6.20000000000000E+02 - 6.05717647058824E+02) / (5.00000000000000E+00 - 4.87941176470588E+00)) { // 118.43902439
        return 5.00000000000000E+00 * x - 6.20000000000000E+02;
    } else if (x < (6.05717647058824E+02 - 3.12000000000000E+02) / (4.87941176470588E+00 - 3.00000000000000E+00)) { // 156.281690141
        return 4.87941176470588E+00 * x - 6.05717647058824E+02;
    } else if (x < (252.0 + 3.12000000000000E+02) / 3.00000000000000E+00) { // 188
        return 3.00000000000000E+00 * x - 3.12000000000000E+02;
    } else {
        return 252.0;
    }
}

float colormap_green(float x) {
    if (x < (2.04536133198612E+02 + 1.47941176470588E+01) / (9.95833333333333E+00 + 1.14822299345429E+00)) {
        return 9.95833333333333E+00 * x - 1.47941176470588E+01;
    } else if (x < (2.72705547652916E+02 - 2.04536133198612E+02) / (1.69701280227596E+00 - 1.14822299345429E+00)) {
        return -1.14822299345429E+00 * x + 2.04536133198612E+02;
    } else if (x < 2.72705547652916E+02 / 1.69701280227596E+00) {
        return -1.69701280227596E+00 * x + 2.72705547652916E+02;
    } else if (x < 7.52000000000000E+02 / 4.00000000000000E+00) {
        return 0.0;
    } else if (x < (7.52000000000000E+02 - 7.45733990147783E+02) / (4.00000000000000E+00 - 3.95785440613027E+00)) {
        return 4.00000000000000E+00 * x - 7.52000000000000E+02;
    } else {
        return 3.95785440613027E+00 * x - 7.45733990147783E+02;
    }
}

float colormap_blue(float x) {
    if (x < (2.50785650623886E+02 + 4.04215299263843E+01) / (1.92690173903766E+00 + 4.23796791443850E-01)) {
        return 1.92690173903766E+00 * x - 4.04215299263843E+01;
    } else if (x < (2.50785650623886E+02 - 1.58221357063404E+02) / (1.75528364849833E-01 + 4.23796791443850E-01)) {
        return -4.23796791443850E-01 * x + 2.50785650623886E+02;
    } else if (x < (1.58221357063404E+02 - 1.27826659541169E+01) / (9.48066572508303E-01 - 1.75528364849833E-01)) {
        return 1.75528364849833E-01 * x + 1.58221357063404E+02;
    } else {
        return 9.48066572508303E-01 * x + 1.27826659541169E+01;
    }
}

vec4 colormap(float x) {
    float t = x * 255.0;
    float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);
    float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);
    float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);
    return vec4(r, g, b, 1.0);
}
